{% extends 'student_score/layout.html' %}
{% block content %}

<div class="layui-form layuimini-form">

    <div class="layui-form-item">
        <label class="layui-form-label required">年级</label>
        <div class="layui-input-block">
             <select name="nianji" lay-verify="required">
                <option value=""></option>
                <option value="一年级">一年级</option>
                <option value="二年级">二年级</option>
                <option value="三年级">三年级</option>
                <option value="四年级">四年级</option>
                <option value="五年级">五年级</option>
                <option value="六年级">六年级</option>
      </select>

        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">班级</label>
        <div class="layui-input-block">
             <select name="banji" lay-verify="required">
                <option value=""></option>
                <option value="一班">一班</option>
                <option value="二班">二班</option>
                <option value="三班">三班</option>
                <option value="四班">四班</option>
                <option value="五班">五班</option>

      </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">学科</label>
        <div class="layui-input-block">
              <select name="xueke" lay-verify="required">
                <option value=""></option>
                <option value="语文">语文</option>
                <option value="数学">数学</option>
                <option value="英语">英语</option>
      </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">任课教师</label>
        <div class="layui-input-block">
             <input type="text" name="name" lay-verify="required" lay-reqtext="任课教师不能为空" placeholder="请输入任课教师" value="" class="layui-input">
        </div>
    </div>


    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
        </div>
    </div>
</div>
{% endblock %}

{% block js %}



<script>
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            var index = layer.alert(JSON.stringify(data.field), {
                title: '最终的提交信息'
            }, function () {
                $.ajax({
                    data:data.field,
                    url:"/teacher-add",
                    type:"POST",
                    dataType:"json",
                    success:function (arg){
                        if(arg.status){

                          parent.layer.close(parent.layer.getFrameIndex(window.name))//关闭当前页
						  // 表格页面重载 parent表示父级表格重载
                          parent.layui.table.reload('currentTableId')



                        }else {
                            var err=arg.msg
                                for (var x in err)
                                {
                                    $("."+x +"_err").text(err[x])
                                }

                        }
                    }
                })

            });

            return false;
        });

    });
</script>
{% endblock %}